#!/usr/bin/env python
# @Software: PyCharm
# @Time : 2022/9/5 15:27
# @Author : v_nahuachen
# @Version：V 0.1
# @File : page_test.py
# @desc :
from cases.base.base_case import BaseCase
from cases.pages import home_page
from cases.pages import base_page


class PageTest(BaseCase):

    def setUp(self) -> None:
        super().setUp()
        # 页面跳转
        self.HomePage.interface_page("page")

    def __init__(self, methodName='runTest'):
        """
        初始化Page实例类
        """
        super(PageTest, self).__init__(methodName)
        self.HomePage = home_page.HomePage(self)
        self.BasePage = base_page.BasePage(self)

    def test_custom_element(self):
        """
        自定义组件定位
        """
        ele = self.BasePage.get_element_custom("mytest>>>test2>>>text")
        self.assertEqual("this is test2", ele.inner_text, "元素定位")

    def test_element_xpath(self):
        """
        xpath定位
        """
        ele = self.BasePage.get_element_xpath("/page/mytest//test2//view/view/text")
        self.assertEqual("this is test2", ele.inner_text, "元素定位")

    def test_base_element(self):
        """
        基础标签元素定位
        """
        ele = self.BasePage.get_element_selector(".waitfor", timeout=5)
        self.assertEqual("wait for", ele.inner_text, "元素定位")

    def test_element_text(self):
        """
        元素text定位
        """
        ele = self.BasePage.get_element_selector_text(".waitfor", inner_text="wait for", timeout=5)
        self.assertEqual("wait for", ele.inner_text, "元素定位")

